<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.lmpop.trade.ts_role.*" %>
<%@page import="com.lmpop.trade.ti_admin.*" %>
<%@page import="java.util.*" %>
<%@page import="com.lmpop.frame.util.PageTools" %>
<%
	request.setCharacterEncoding("UTF-8");
	Map ts_role = new Hashtable();
	String s_title = "";
	if(request.getParameter("s_title")!=null && !request.getParameter("s_title").equals("")){
		s_title = request.getParameter("s_title");
		ts_role.put("role_name",s_title);
	}
	String s_cust_id = "";	
	if( session.getAttribute("session_cust_id") != null ){
		s_cust_id = session.getAttribute("session_cust_id").toString();
		ts_role.put("cust_id",s_cust_id);
	}
	
	Ts_roleInfo ts_roleInfo = new Ts_roleInfo();
	String iStart = "0";
	int limit = 20;
	if(request.getParameter("iStart")!=null) iStart = request.getParameter("iStart");
	List list = ts_roleInfo.getListByPage(ts_role,Integer.parseInt(iStart),limit);
	int counter = ts_roleInfo.getCountByObj(ts_role);
	String pageString = new PageTools().getGoogleToolsBar(counter,"index.jsp?s_title="+s_title+"&iStart=",Integer.parseInt(iStart),limit);
	
	String para = "s_title="+s_title+"&iStart="+Integer.parseInt(iStart);
%>
<html>
  <head>
    <title>角色管理</title>
		<link href="/program/admin/index/css/style.css" rel="stylesheet" type="text/css">
		<script type="text/javascript" src="/js/commen.js"></script>
		<script type="text/javascript" src="role.js" charset="UTF-8"></script>
</head>

<body>
	<table width="100%" cellpadding="0" cellspacing="0" border="0">
		<tr>
			<td width="90%">
				<h1>角色管理</h1>
			</td>
			<td>
				<a href="addInfo.jsp"><img src="/program/admin/index/images/post.gif" /></a>
			</td>
		</tr>
	</table>
	
	<form action="index.jsp" name="indexForm" method="post">
	
	<table width="100%" cellpadding="0" cellspacing="0" class="dl_su">
		<tr>
			<td align="left">
				角色:<input name="s_title" type="text" />
				<input name="searchInfo" type="submit" value="查询" />	
			</td>
		</tr>
	</table>

	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="tablehe">
		<tr><td align="center" ><%=pageString %></td></tr>
	</table>
	
	<% 
		int listsize = 0;
		if(list!=null && list.size()>0){
			listsize = list.size();
	%>
	
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="dl_bg">
		<tr>
			<td width="90%">
				<input type="button" name="delInfo" onclick="delIndexInfos()" value="删除" class="buttab"/>
			</td>
			<td>
				总计:<%=counter %>条
			</td>
		</tr>
	</table>
	
	<table width="100%" cellpadding="1" cellspacing="1" class="listtab" border="0">
		<tr>
			<th width="5%" align="center"><input type="checkbox" name="checkall" id="checkall" onclick="selectAll()"></th>
			
		  	<th>角色名称</th>
		  	
			<th width="10%">修改</th>
	  		<th width="10%">删除</th>
		</tr>
		
		
		<% 
		  		for(int i=0;i<list.size();i++){
		  			Hashtable map = (Hashtable)list.get(i);
		  			String role_code="",role_name="",cust_id="";
		  			  	if(map.get("role_code")!=null) role_code = map.get("role_code").toString();
						  	if(map.get("role_name")!=null) role_name = map.get("role_name").toString();
						  	if(map.get("cust_id")!=null) cust_id = map.get("cust_id").toString();
						  	
						  	int hasDown = new Ti_adminInfo().checkRole(role_code);
		  %>
		
		<tr>
			<td width="5%" align="center">
				<input type="checkbox" name="checkone<%=i%>" id="checkone<%=i %>" value="<%=role_code%>" />
				<input type="hidden" name="hasDown<%=i%>" id="hasDown<%=i%>" value="<%=hasDown%>" />
			</td>
			
		  	<td><%=role_name%></td>
		  	
		  
		  	
			<td width="10%"><a href="addInfo.jsp?role_code=<%=role_code%>&flag=1&<%=para%>"><img src="/program/admin/images/edit.gif" title="修改" /></a></td>
			<%
				if(hasDown == 0){
			%>
  			<td width="10%"><a href="javascript:delOneNews('<%=role_code%>');"><img src="/program/admin/images/delete.gif" title="删除" /></a></td>
			<%
			}
			%>
  		<%
				if(hasDown == 1){
			%>
  			<td width="10%"><a href="javascript:hasdown()"><img src="/program/admin/images/delete.gif" title="删除" /></a></td>
			<%
			}
			%>
		</tr>
		
		  <%
		  		}
		  %>
		
	</table>
	
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="dl_bg">
		<tr>
			<td width="90%">
				<input type="button" name="delInfo" onclick="delIndexInfos()" value="删除" class="buttab"/>
			</td>
			<td>
				总计:<%=counter %>条
			</td>
		</tr>
	</table>
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="tablehe">
		<tr><td align="center" ><%=pageString %></td></tr>
	</table>
	
	<%
		 }
	%>
	
	  <input type="hidden" name="listsize" id="listsize" value="<%=listsize %>" />
	  <input type="hidden" name="pkid" id="pkid" value="" />
	  <input type="hidden" name="bpm_id" id="bpm_id" value="9283" />
	  </form>
</body>

</html>
